/////////////////////////////////////////////////////////////////////////////
// Name:        ax_fallbacks.h
// Purpose:     Fallbacks classes
// Author:      Julian Smart
// Modified by:
// Created:     2009-03-20
// RCS-ID:
// Copyright:   (c) Julian Smart
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _AX_FALLBACKS_H_
#define _AX_FALLBACKS_H_

/*
 * Includes
 */

#include "ax_resource/ax_resource.h"
#include "ax_resource/ax_module.h"

/**
    @class AxFileResource

    A resource representing arbitrary files, used with AxFallbackModule.

    @category{ax_resource}
 */

class AxFileResource: public AxResource
{
    DECLARE_DYNAMIC_CLASS( AxFileResource )

public:
// Constructors

    AxFileResource(const AxFileResource& resource) { Init(); Copy(resource); }
    AxFileResource() { Init(); }
    ~AxFileResource();

// Operations

    void Init();

    /// Copy the resource information.
    void Copy(const AxFileResource& resource) { AxResource::Copy(resource); }

    /// Clone - derived classes must implement this function.
    virtual AxDocument* Clone() const { return new AxFileResource(*this); }

protected:

};

/**
    @class AxFallbackModule

    A module for dealing with files not dealt with by other modules.

    @category{ax_resource}
 */

class AxFallbackModule: public AxModule
{
DECLARE_DYNAMIC_CLASS(AxFallbackModule)

public:
    /// Constructor.
    AxFallbackModule();

    /// Destructor.
    ~AxFallbackModule() {}

// Overridables

    /// Called on IDE startup, before the main window has been created.
    virtual bool OnInit();

    /// Called on application startup, after the main window has been created.
    virtual bool OnInitUI();

 	/// Called just before program termination, but only if OnInit()
    /// succeeded.
    virtual void OnExit();

	/// Read config settings
	virtual bool LoadConfig(wxConfigBase& config);

	/// Write config settings
    virtual bool SaveConfig(wxConfigBase& config);

    // Called just before the frame is closed. Return false vetoes
    // the frame/app close.
    virtual bool OnCloseMainWindow() { return true; }

    // Allows app to search amongst its own objects. Call AxResourceLibrary::AddSearchItem
    // for each item.
    virtual bool OnSearch(const wxString& WXUNUSED(searchString), int WXUNUSED(flags), AxResourceLibrary* WXUNUSED(library)) { return false; }

    /// Is this file supported?
    virtual bool IsFileSupported(const wxString& filename);

    /// Load the file into a new AxResource
    virtual AxResource* LoadResource(const wxString& filename);

    /// Aggregate any files that belong together and add to resources. Return false if you don't
    /// aggregate any files.
    virtual bool AggregateFiles(AxResourceLibrary* library, wxArrayString& files, bool checkIfFileLoaded);

    /// Create an activator for the resource, for creating views and further menu items.
    virtual AxActivator* CreateActivator(AxResourceLibrary* library, AxResource* resource);

// Accessors

    /// Fallbacks enabled
    static bool GetFallbacksEnabled() { return sm_fallbacksEnabled; }

    /// Enable fallbacks
    static void EnableFallbacks(bool enabled) { sm_fallbacksEnabled = enabled; }

protected:
    static bool             sm_fallbacksEnabled;
};

#endif
    // _AX_FALLBACKS_H_
